<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="./style.css">
  <title>月嫂报价</title>
</head>
<body>
  <div class="layer quoted">
    <section class="section" id="form1">
      <div class="box box-form">
        <img src="./images/top_logo.png" class="logo" alt="">
        <img src="./images/top_text.png" alt="" class="form-title">
        <form class="form">
          <select name="" id="" class="form-control city-select">
            <option value="">所在城市</option>
            <option value="北京">北京</option>
          </select>
          <select name="" id="" class="form-control ayi-select">
            <option value="">阿姨类别</option>
            <option value="月嫂">月嫂</option>
            <option value="育儿嫂">育儿嫂</option>
          </select>
          <input type="text" id="datePicker1" class="form-control date-input icon-select" placeholder="您的预产期/宝宝生日" readonly>
          <input type="text" class="form-control phone-input" placeholder="请输入您的手机号">
          <p class="form-price">
            <span>您查询的服务价格为:</span>
            <span><img src="./images/pic_numg.gif" />元</span>
          </p>
          <button class="btn btn-block btn-submit" type="button">点击查询价格</button>
        </form>
      </div>
      <div class="box box-care">
        <img src="./images/ysbj_04.jpg" alt="">
        <img src="./images/ysbj_05.jpg" alt="">
        <a href="#" class="btn btn-block btn-kefu"  onclick="doyoo.util.openChat('g=10082418');return false;" type="button">了解更多>></a>
      </div>
      <div class="box box-mode">
        <img src="./images/ysbj_07.jpg" alt="">
        <img src="./images/ysbj_08.jpg" alt="">
        <img src="./images/form_title.png" alt="">
        <form class="form">
          <div class="form-banner">
            <h4>您查询的月嫂/育儿嫂的服务价格</h4>
            <div class="price-board">
              <img src="./images/pic_num.gif" alt=""><span>元</span>
            </div>
          </div>
          <div class="form-main">
            <select name="" id="" class="form-control city-select">
              <option value="">所在城市</option>
              <option value="北京">北京</option>
            </select>
            <select name="" id="" class="form-control ayi-select">
              <option value="">阿姨类别</option>
              <option value="月嫂">月嫂</option>
              <option value="育儿嫂">育儿嫂</option>
            </select>
            <input type="text" id="datePicker2" class="form-control date-input icon-select" placeholder="您的预产期/宝宝生日" readonly>
            <input type="text" class="form-control phone-input" placeholder="请输入您的手机号">
            <button class="btn btn-block btn-submit" type="button">免费测试</button>
          </div>

        </form>
      </div>
    </section>
    <footer class="fixed-footer">
      <div class="footer-menu">
        
        <span class="menu-item">
          <img src="./images/btn_zixun.png" alt="" onclick="doyoo.util.openChat('g=10082418');return false;">
          <span>点我咨询</span>
        </span>
        <a class="menu-item" href="tel:18600838147">
          <img class="icon-tel" src="./images/btn_tel.gif" alt="">
          <span>一键通话</span>
        </a>
        <a class="menu-item" href="#form1">
          <img src="./images/btn_chaxun.png" alt="">
          <span>价格查询</span>
        </a>
      </div>
    </footer>
  </div>
  <script src="./jquery.min.js"></script>
  <script src="datePicker.js"></script>
  <script>
    ;!function ($) {
      var getcityListUrl = 'http://admin.mumway.com/index/activity/cityList';
      
      var submitUrl = 'http://admin.mumway.com/index/activity/addServiceOffers';
      var method = 'POST'
      var cityList;
      var unSelected = "#999";
      var selected = "#000";
      var calendar1 = new datePicker();
      var calendar2 = new datePicker();

      calendar1.init({
        'trigger': '#datePicker1', /*按钮选择器，用于触发弹出插件*/
        'type': 'date',/*模式：date日期；datetime日期时间；time时间；ym年月；*/
        'minDate':'2016-1-1',/*最小日期*/
        'maxDate':'2022-12-31',/*最大日期*/
        'onSubmit':function(){/*确认时触发事件*/
          //var theSelectData=calendar.value;
        },
        'onClose':function(){/*取消时触发事件*/
        }
      });
    
      calendar2.init({
        'trigger': '#datePicker2',
        'type': 'date',
        'minDate':'2016-1-1',
        'maxDate':'2022-12-31'
      });

      $("select").css("color", unSelected);
      $("option").css("color", selected);
      $("select").change(function () {
          var selItem = $(this).val();
          if (selItem == $(this).find('option:first').val()) {
              $(this).css("color", unSelected);
          } else {
              $(this).css("color", selected);
          }
      });

      //获得并设置城市列表
      $.post( getcityListUrl, function( data ) {
       //console.log(data)
       cityList = data.data || [];
       var cityOptions = '<option value="">选择城市</option>';
       for(var i= 0; i< cityList.length; i++){
        cityOptions += '<option style="color: #000" value="' + cityList[i].name + '">' + cityList[i].name + '</option>'
       }
       $('.city-select').html(
        cityOptions
       );
      });
      // 设置阿姨类型的不同，日期也会改变

      $(".ayi-select").change(function () {
        var $this = $(this);
        var curAyiType = $this.find('option:selected').val();
        var $dateInput = $this.parent().parent().find('.date-input');
        if (curAyiType === '月嫂') {
          $dateInput.prop({placeholder: '您的预产期'});
          if($dateInput.val() && +$dateInput.val().slice(0, 4) < 2019){
            $dateInput.val('');
          }
          calendar1.minY = 2019;
          calendar2.minY = 2019;
        }else { // 育儿嫂
          $dateInput.prop({placeholder: '您的宝宝生日'});
          calendar1.minY = 2016;
          calendar2.minY = 2016;
        }
      });  

      /*                提交表单               */

      var submitBtn = $('.btn-submit');
      submitBtn.click(function(){
        var $form = $(this).parent();
        var selPhone = $form.find('.phone-input').val();
        var selDate = $form.find('.date-input').val();
        var selCity = $form.find('.city-select option:selected').val();
        var selAyi = $form.find('.ayi-select option:selected').val().trim();
        var phoneReg=/^[1][3,4,5,7,8,9][0-9]{9}$/;
        //console.log(selPhone, selDate, selCity, selAyi);
        if(!selPhone || !selDate || !selCity || !selAyi) return alert('信息填写不完整！');
        if(!phoneReg.test(selPhone)) return alert('手机号格式不正确');
        var row = {
              work_type: selAyi,
              phone: selPhone,
              city: selCity,
              expected_date: selDate,
              source_url: window.location.href
            }
        $.ajax({
          url: submitUrl,
          type: method,
          dataType: 'json',
          data: {
            "row": row
          },
          success:function(msg){
            if(msg.success){
              alert('您已申请成功，我们会有专业的母婴顾问给您做详细的介绍，请注意接听电话，感谢您的信任！');
            }else{
              alert(msg.msg || '预约失败,请重试');
            }
          }
        });
      });


    }(jQuery);

  </script>
  <script type="text/javascript" charset="utf-8" src="http://lead.soperson.com/10042070/10104213.js"></script>
  <script>
    var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?b53e84d07d4130757bfe4ef58dbd1231"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> 
    <script type="text/javascript" charset="utf-8" async src="http://lxbjs.baidu.com/lxb.js?sid=13267162"></script>
  
</body>
</html>